/*
 * @Author: your name
 * @Date: 2020-12-28 17:11:34
 * @LastEditTime: 2021-01-04 16:26:06
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \H5 2010 studyd:\H5 2010 练习\第三阶段 Vue + node\DAY 7\panda\src\router\routes.js
 */
// @ 是 src 目录的别名
import Home from "@/views/home";
import Mine from "@/views/mine";
import Cart from "@/views/cart";
import Detail from "@/views/detail";
import Login from "@/views/login";
import Order from "@/views/order";
import Category from "@/views/category";
import SubCategory from "@/views/category/SubCategory";

import NavBar from "@/components/nav-bar";
import TabBar from "@/components/tab-bar";

const routes = [
  {
    path: "/",
    redirect: "/home" // 重定向
  },
  {
    path: "/home",
    name: "Home",
    components: {
      header: NavBar,
      footer: TabBar,
      main: Home
    },
    meta: {
      isTab: true,
      title: "首页",
      icon: "home-o",
      isSearch: true
    }
  },
  {
    path: "/category",
    name: "Category",
    // redirect: '/category/sub/2', // 重定向
    components: {
      header: NavBar,
      footer: TabBar,
      main: Category
    },
    meta: {
      isTab: true,
      title: "分类",
      icon: "apps-o"
    },
    children: [
      // 嵌套路由 （子路由）
      {
        path: "sub/:cid", // 以 : 标记的是 "动态路径参数"
        name: "SubCategory",
        component: SubCategory,
        meta: {
          title: "子分类"
        }
      }
    ]
  },
  {
    path: "/cart",
    name: "Cart",
    components: {
      header: NavBar,
      footer: TabBar,
      main: Cart
    },
    meta: {
      isTab: true,
      title: "购物车",
      icon: "shopping-cart-o",
      isBadge: true
    }
  },
  {
    path: "/mine",
    name: "Mine", // 命名路由
    components: {
      header: NavBar,
      footer: TabBar,
      main: Mine
    },
    meta: {
      isTab: true, // true 表示是需要添加到 TabBar 上显示渲染并跳转
      title: "我的",
      icon: "user-o"
    }
  },
  {
    path: "/detail",
    name: "Detail",
    components: {
      header: NavBar,
      main: Detail
    },
    meta: {
      title: "详情"
    }
  },
  {
    path: "/login",
    name: "Login",
    components: {
      header: NavBar,
      main: Login
    },
    meta: {
      title: "用户登录"
    }
  },
  {
    path: "/order",
    name: "Order",
    components: {
      header: NavBar,
      main: Order
    },
    meta: {
      title: "历史订单"
    }
  }
];

export default routes;
